import os, sys
from tensorflow.python.platform import gfile
import tensorflow as tf

def get_all_layernames(pb_file_path):
    #get all layers name 
    
    sess = tf.compat.v1.Session()
    with gfile.FastGFile(pb_file_path, 'rb') as f:
        graph_def = tf.compat.v1.GraphDef()
        graph_def.ParseFromString(f.read())
        sess.graph.as_default()
        tf.compat.v1.import_graph_def(graph_def, name='')

        tensor_name_list = [tensor.name for tensor in tf.compat.v1.get_default_graph().as_graph_def().node]
        for tensor_name in tensor_name_list:
            print(tensor_name)
            
            
if __name__ == '__main__':
    if len(sys.argv) == 2:
        get_all_layernames(sys.argv[1])